//
//  WindowController.m
//  RayTracer
//
//  Created by 俞云康 on 4/4/16.
//  Copyright © 2016 yushroom. All rights reserved.
//

#import "WindowController.h"
#import "ViewController.h"

@interface WindowController ()
@property (weak) IBOutlet NSToolbar *mToolBar;
@property (weak) IBOutlet NSToolbarItem *mRenderButton;
@property (weak) IBOutlet NSToolbarItem *mRenderRegionButton;
@end

@implementation WindowController

- (IBAction)onRenderButtonClick:(NSToolbarItem *)sender {
    //NSLog(@"RenderButtonClick");
    ViewController* vc = (ViewController*)self.window.contentViewController;
    [vc setXMLFilePath:@""];
    [vc render];
}

- (IBAction)onRenderRegionButtonClick:(NSToolbarItem *)sender {
    ViewController* vc = (ViewController*)self.window.contentViewController;
    [vc renderRegion];
}

- (IBAction)onRenderPixelButtonClick:(NSToolbarItem *)sender {
    ViewController* vc = (ViewController*)self.window.contentViewController;
    [vc renderPixel];
}

- (IBAction)onClearButtonClick:(NSToolbarItem *)sender {
    ViewController* vc = (ViewController*)self.window.contentViewController;
    [vc clear];
}

- (void)resize:(int) X andY: (int) Y {
    NSLog(@"clear");
    NSRect frame = [self.window frame];
    NSRect viewFrame = [self.window.contentView frame];
    NSLog(@"old frame: %lf %lf", frame.size.width, frame.size.height);
    NSLog(@"old viewFrame: %lf %lf", viewFrame.size.width, viewFrame.size.height);
    frame.size.width = X + frame.size.width - viewFrame.size.width;
    frame.size.height = Y + frame.size.height - viewFrame.size.height;
    [self.window setFrame:frame display:YES animate:YES];
    //[self.window setViewsNeedDisplay:YES];
}

- (void)windowDidLoad {
    [super windowDidLoad];
    //[self window].titleVisibility = NSWindowTitleHidden;
    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

@end
